package com.wtone.platform.gat.images.gat.controller;


import com.wtone.platform.gat.images.gat.core.BaseController;
import com.wtone.platform.gat.images.gat.core.R;
import com.wtone.platform.gat.images.gat.entity.DeviceInfo;
import com.wtone.platform.gat.images.gat.service.IDeviceInfoService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author aiLin
 * @date 2020-10-12
 * @desc:设备信息 提供者
 */
@Api(tags = "设备信息DB", value = "DeviceInfo api")
@RestController
@RequestMapping("info")
public class DeviceInfoController extends BaseController
{

	@Autowired
	private IDeviceInfoService deviceInfoService;

	@ApiOperation(value = "根据卡片id查询设备信息信息" , position = 10)
	@GetMapping("get/{id}")
	public DeviceInfo get(@PathVariable("id") String id){
		return deviceInfoService.selectDeviceInfoById(id);
	}

	@ApiOperation(value = "查询设备信息列表", position = 10)
	@ApiResponses(value = {
			@ApiResponse(code = 200, message="List结果集",response= DeviceInfo.class),
			@ApiResponse(code = 404, message = "not found error")
	})
	@ApiImplicitParam(name = "params", value = "请求参数", required = false, paramType="path", dataType = "MAP")
	@GetMapping("list")
	public R list(DeviceInfo deviceInfo){
		startPage();
		return result(deviceInfoService.selectDeviceInfoList(deviceInfo));
	}

	@ApiOperation(value = "新增设备信息", position = 1)
	@PostMapping("save")
	public R addSave(@RequestBody DeviceInfo deviceInfo){
		return toAjax(deviceInfoService.insertDeviceInfo(deviceInfo));
	}


	@ApiOperation(value = "修改设备信息", position = 2)
	@PostMapping("update")
	public R editSave(@RequestBody DeviceInfo deviceInfo){
		return toAjax(deviceInfoService.updateDeviceInfo(deviceInfo));
	}


	@ApiOperation(value = "根据卡片id删除设备信息", position = 3)
	@PostMapping("remove")
	public R remove(String ids)
	{
		return toAjax(deviceInfoService.deleteDeviceInfoByIds(ids));
	}

}
